package com.xwx.common.config;
import org.apache.log4j.Logger;

import com.jfinal.config.Constants;
import com.jfinal.config.Handlers;
import com.jfinal.config.Interceptors;
import com.jfinal.config.JFinalConfig;
import com.jfinal.config.Plugins;
import com.jfinal.config.Routes;
import com.jfinal.core.JFinal;
import com.jfinal.ext.handler.ContextPathHandler;
import com.jfinal.kit.PropKit;
import com.jfinal.render.ViewType;
import com.xwx.common.interceptor.ErrorLogInterceptor;
import com.xwx.common.interceptor.OperLogInterceptor;
/** 
* @Description:提供基础的配置
* configConstant基本可 以不动
* configPlugin默认配置了core,web需自己配置
* configInterceptro默认配置了错误与操作日志拦截 
* configHandler默认配置了ContextPathHandler  devPath
* @author:Dream QQ:68697015
* @time:2015年8月31日 上午11:30:50
*/
public abstract  class AppConfigExt extends JFinalConfig{
	@Override
	public abstract void configRoute(Routes me);
	@Override
	public abstract void configPlugin(Plugins me);
	@Override
	public void configHandler(Handlers me) {
		me.add(new ContextPathHandler("devPath"));
	}
	protected Logger log=Logger.getLogger(getClass());
	@Override
	public void configConstant(Constants me) {
		PropKit.use("AppConfig.txt");//全局配置
		me.setBaseViewPath(PropKit.get("baseViewPath"));
		me.setDevMode(PropKit.getBoolean("devMode",true));
		me.setFileRenderPath(PropKit.get("uploadFile"));
		me.setUploadedFileSaveDirectory(PropKit.get("uploadFile"));
		me.setViewType(ViewType.JSP);
		me.setError404View(PropKit.get("error404"));
		JFinal.me().getServletContext().setAttribute("appTitle", PropKit.get("appTitle"));
		log.info("全局参数加载成功");
	}
	@Override
	public void configInterceptor(Interceptors me) {
		me.add(new ErrorLogInterceptor());
		log.info("全局异常统一处理加载成功");
		me.add(new OperLogInterceptor());
		log.info("全局操作日志处理加载成功");
	}
}
